﻿<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>pos-storehouse</title>
	<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
	<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
	<header class="navbar-fixed-top">
		<div class="navbar-header">
			<span class="glyphicon glyphicon-option-vertical"></span>
			<label>服装店Pos管理系统</label>
		</div>
		<div>
			<ul class="nav navbar-nav navbar-right">
				<li><a>欢迎你！</a></li>
				<li><a href="#">个人信息</a></li>
				<li><a id="loginOrOut" href="" ></a></li>
			</ul>
		</div>
	</header>
	<nav class="navbar navbar-default nav-bgcolor navbar-fixed-top nav-vertical">
		<div class="container-fluid">
			<ul class="nav nav-stacked">
				<li><a href="storehouse.html" >商品管理</a></li>
				<li><a href="order.html">订单管理</a></li>
				<li><a href="#">会员管理</a></li>
				<li id="showQuanXian"><a href="quanxian.html">员工管理</a></li>
				<li><a href="cashier.html">支付</a></li>
			</ul>
		</div>
	</nav>
	<main>
		<div id="nav-tab">
			<ul class="nav nav-tabs">
				<li class="active"><a data-toggle="tab" href="#good-table">商品列表</a></li>
				<li><a data-toggle="tab" href="#">商品品牌</a></li>
			</ul>
			<div class="tab-content">
				<div id="good-table" class="table tab-pane fade in active">
					<form class="form-inline form-table" role="form">
						<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#addGood">添加商品</button>
						<div class="input-group">
							<input type="text" id="findGood" class="form-control input-group-addon" name="search" placeholder="请输入goodNo">
							<span class="input-group-btn"><button type="button" onclick="searchGood(this)" class="btn btn-default">查找</button></span>
						</div>
					</form>
					<table align="center" class="table table-striped table-hover" >
						<thead>
							<tr>
								<th style="display:none">id</th><th>编号</th><th>名称</th><th style="display:none">clazzId</th><th style="display:none">brandId</th><th style="display:none">supplierId</th><th>操作</th>
							</tr>
						</thead>
						<tbody id="goodList">
						</tbody>
					</table>
				</div><!-- /.#good-table -->
			</div><!-- /.good-content -->
		</div><!-- /.nav-tab -->
	</main>
	
	<!-- 添加商品的表格  -->
	<div id="addGood" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="add good" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					<h4>添加商品种类</h4>
				</div>
				<div class="modal-body">
					<form role="form">
						<div class="form-group">
							<label>编号</label>
							<input id="goodNo" type="text" class="form-control" name="goodNo" >
						</div>
						<div class="form-group">
							<label>种类</label>
							<select id="clazzName" class="form-control">
							</select>
						</div>
						<div class="form-group">
							<label>品牌</label>
							<select id="brandName" class="form-control">
							</select>
						</div>
						<div class="form-group">
							<label>生产商</label>
							<select id="supplierName" class="form-control">
							</select>
						</div>
						<div class="form-group">
							<label>名称</label>
							<input id="title" type="text" class="form-control" name="title">
						</div>
						<div class="form-group">
							<label>价格</label>
							<input id="price" type="number" class="form-control" name="price">
						</div>
						<div class="form-group">
							<label>尺寸</label>
							<select id="size" class="form-control">
								<option value="S">S</option>
								<option value="M">M</option>
								<option value="L">L</option>
							</select>
						</div>
						<div class="form-group">
							<label>颜色</label>
							<input id="color" type="text" class="form-control" name="color">
						</div>
						<div class="form-group">
							<label>性别</label>
							<select id="gender" class="form-control">
								<option value="不限">不限</option>
								<option value="女">女</option>
								<option value="男">男</option>
							</select>
						</div>
						<div class="form-group">
							<label>年龄段</label>
							<select id="age" class="form-control">
								<option value="不限">不限</option>
								<option value="青年">青年</option>
								<option value="中年">中年</option>
								<option value="老年">老年</option>
							</select>
						</div>
						<div class="form-group">
							<label>仓库名</label>
							<select id="repositName" class="form-control">
							</select>
						</div>
						<div class="form-group">
							<label>数量</label>
							<input id="count" type="text" class="form-control" name="count">
						</div>
					</form>
				</div><!-- /.modal-body -->
				<div class="modal-footer">
					<button type="submit" class="btn btn-default" onclick="addForm()">提&nbsp;&nbsp;&nbsp;交</button>
					<button type="reset" class="btn btn-default" onclick="resetForm(this)">重&nbsp;&nbsp;&nbsp;置</button>
				</div>
			</div><!-- /.modal-content -->
		</div><!-- /.modal-dialog -->
	</div><!-- /.#addGood -->
	
	<!-- 显示good的doodDetail -->
	<div id="showGoodDetail" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="search goodDetail" aria-hidden="true" data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" data-dismiss="modal" class="close" onclick="resetGoodDetailList();">&times;</button>
					<h4>商品详情</h4>
				</div><!-- /.modal-header -->
				<div class="modal-body">
					<table id="goodDetailList" class="table table-head">
						<colgroup>
							<col width="23%"/><col width="13%"/><col width="13%"/><col width="13%"/><col width="10%"/><col width="10%"/><col width="10%"/><col width="14%"/>
						</colgroup>
						<thead>
							<tr>
								<th style="display:none">detailId</th><th style='text-align:center'>品名</th><th>价格</th><th>尺寸</th><th>年龄</th><th>颜色</th><th>性别</th><th>库存</th><th style='text-align:center' id="btn-cz">操作</th>
							</tr>
						</thead>
						<tbody  class="table">
									
						</tbody>
					</table>
				</div><!-- /.modal-body -->
				<div class="modal-footer">
					<button type="button" class="btn btn-default" id="btn-getGoodId" onclick="showAddDetailModal(this)">添加</button>
					<button type="button" class="btn btn-default" data-dismiss="modal" onclick="resetGoodDetailList();">完成</button>
				</div><!-- /.modal-footer -->
			</div><!-- /.modal-content -->
		</div>
	</div>	
	
	<!-- 添加doodDetail -->
	<div id="addGoodDetail" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="search goodDetail" aria-hidden="true" data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" data-dismiss="modal" class="close">&times;</button>
					<h4>添加商品</h4>
				</div><!-- /.modal-header -->
				<div class="modal-body">
					<form role="form">
						<input style="display:none" id="goodId" ></input>
						<div class="form-group">
							<label>价格</label>
							<input id="detailPrice" type="number" class="form-control" name="price">
						</div>
						<div class="form-group">
							<label>尺寸</label>
							<select id="detailSize" class="form-control">
								<option value="S">S</option>
								<option value="M">M</option>
								<option value="L">L</option>
							</select>
						</div>
						<div class="form-group">
							<label>颜色</label>
							<input id="detailColor" type="text" class="form-control" name="color">
						</div>
						<div class="form-group">
							<label>性别</label>
							<select id="detailGender" class="form-control">
								<option value="不限">不限</option>
								<option value="女">女</option>
								<option value="男">男</option>
							</select>
						</div>
						<div class="form-group">
							<label>年龄段</label>
							<select id="detailAge" class="form-control">
								<option value="不限">不限</option>
								<option value="青年">青年</option>
								<option value="中年">中年</option>
								<option value="老年">老年</option>
							</select>
						</div>
						<div class="form-group">
							<label>仓库名</label>
							<select id="detailRepositName" class="form-control">
							</select>
						</div>
						<div class="form-group">
							<label>数量</label>
							<input id="detailCount" type="text" class="form-control" name="count">
						</div>
					</form>
				</div><!-- /.modal-body -->
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal" onclick="addGoodDetail(this)">完成</button>
					<button type="button" class="btn btn-default" onclick="resetForm(this)">重置</button>
				</div><!-- /.modal-footer -->
			</div><!-- /.modal-content -->
		</div>
	</div>
	
	<!-- 更新goodDetail -->
	<div id="updateGoodDetail" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="search goodDetail" aria-hidden="true" data-backdrop="static">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" data-dismiss="modal" class="close">&times;</button>
					<h4>更新商品详情</h4>
				</div><!-- /.modal-header -->
				<div class="modal-body">
					<form role="form">
						<input style="display:none" id="updatedetailid" type="text" class="form-control" name="detailid">
						<input style="display:none" id="updatestockid" type="text" class="form-control" name="stockid">
						<input style="display:none" id="updategoodid" type="text" class="form-control" name="goodid">
						<div class="form-group">
							<label>价格</label>
							<input id="updateprice" type="text" class="form-control" name="price">
						</div>
						<div class="form-group">
							<label>尺寸</label>
							<select id="updatesize" class="form-control">
								<option value="S">S</option>
								<option value="M">M</option>
								<option value="L">L</option>
							</select>
						</div>
						<div class="form-group">
							<label>颜色</label>
							<input id="updatecolor" type="text" class="form-control" name="color">
						</div>
						<div class="form-group">
							<label>性别</label>
							<select id="updategender" class="form-control">
								<option value="不限">不限</option>
								<option value="女">女</option>
								<option value="男">男</option>
							</select>
						</div>
						<div class="form-group">
							<label>年龄段</label>
							<select id="updateage" class="form-control">
								<option value="不限">不限</option>
								<option value="青年">青年</option>
								<option value="中年">中年</option>
								<option value="老年">老年</option>
							</select>
						</div>
					</form>
				</div><!-- /.modal-body -->
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal" onclick="updateGoodDetail(this)">完成</button>
					<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
				</div><!-- /.modal-footer -->
			</div><!-- /.modal-content -->
		</div>
	</div>				
	<script src="js/jquery-3.2.1.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){

			render();
			
			
			$.ajax({
				url : '/ClothesShopPOS/clazz/list',
				type : "get",
				cache : false,
				success : function(data) {//渲染clazz下拉框
					var resultList=JSON.parse(data).result;
					var select=$("#clazzName");
					
					for(var i in resultList){
						var temp=$("<option value="+resultList[i].id+">"+resultList[i].name+"</option>");
						temp.appendTo(select);
					}
				}
			})
			
			$.ajax({
				url : '/ClothesShopPOS/brand/list',
				type : "get",
				cache : false,
				success : function(data) {//渲染brand下拉框
					var resultList=JSON.parse(data).result;
					var select=$("#brandName");
					
					for(var i in resultList){
						var temp=$("<option value="+resultList[i].id+">"+resultList[i].name+"</option>");
						temp.appendTo(select);
					}
				}
			})
			
			$.ajax({
				url : '/ClothesShopPOS/supplier/list',
				type : "get",
				cache : false,
				success : function(data) {//渲染supplier下拉框
					var resultList=JSON.parse(data).result;
					var select=$("#supplierName");
					
					for(var i in resultList){
						var temp=$("<option value="+resultList[i].id+">"+resultList[i].name+"</option>");
						temp.appendTo(select);
					}
				}
			})
			
			$.ajax({
				url : '/ClothesShopPOS/reposit/list',
				type : "get",
				cache : false,
				success : function(data) {//渲染reposit下拉框
					var resultList=JSON.parse(data).result;
					var select=$("#repositName,#detailRepositName");
					
					for(var i in resultList){
						var temp=$("<option value="+resultList[i].id+">"+resultList[i].name+"</option>");
						temp.appendTo(select);
					}
				}
			})
			
			$.ajax({
				url : '/ClothesShopPOS/log/check_login',
                type: "get",
                cache : false,
                success : function(data) {
                    console.log(data);
                    data = JSON.parse(data);
                    if (data=='0'){
                        $("#loginOrOut").html("登录");
                        $("#loginOrOut").attr("href","login.html");
                    }else if(data=='1'){
                       $("#loginOrOut").html("退出");      
                       $("#loginOrOut").click(function(){
                       		if(confirm("确认退出吗？")){
                       			$.ajax({
		                       		url : '/ClothesShopPOS/log/logout',
					                type: "post",
					                cache : false,
					                success : function(data) {
					                	console.log(data);
		                    			data = JSON.parse(data);
		                    			if(data.statusCode=='0'){
		                    				alert("退出成功");
		                    				window.location.href="login.html";
		                    			}else{
		                    				alert("失败");
		                    			}
					                }
		                     	}) 
                       		}
                       });                
                	}
                }
			})
			
			$.ajax({
				url : '/ClothesShopPOS/log/check_superadmin',
                type: "get",
                cache : false,
                success : function(data) {
                	console.log(data);
           			data = JSON.parse(data);
           			if(data=='0'){
           				//alert("成功");
           				$("#showQuanXian").remove();
           			}
                }
			})
	
		});
		
		/*********渲染表格*************/
		function render(){
			$.ajax({
				url : '/ClothesShopPOS/good/list',
				type : "get",
				cache : false,
				success : function(data) {
					//var goodObj=JSON.parse(data);
					var resultList=JSON.parse(data).result;
					var table=$("#goodList");
					
					for(var i in resultList){
						var temp=$("<tr><td style='display:none;'>"+resultList[i].id+"</td><td>"+resultList[i].goodNo+"</td>"
						+"<td>"+resultList[i].title+"</td><td style='display:none;'>"+resultList[i].clazzId+"</td>"
						+"<td style='display:none;'>"+resultList[i].brandId+"</td><td style='display:none;'>"+resultList[i].supplierId+"</td>"
						+"<td><button type='button' class='btn btn-default' onclick='showGoodDetail(this);'>详情</button>&nbsp;&nbsp;<button class='btn btn-default' onclick='delGood(this);'>删除</button></td></tr>"
						);
						temp.appendTo(table);
					}
				}
			})
		}
		
		/*添加商品*/
		function addForm(){
			var good={
				"goodNo":$("#goodNo").val(),
				"title":$("#title").val(),
                "clazzId":$("#clazzName").val(),	// TODO
                "brandId":$("#brandName").val(),	// TODO
                "supplierId":$("#supplierName").val()	// TODO
			};

			var goodDetailList=new Array();
			goodDetailList.push({
				"referencePrice" : $("#price").val(),
				"size" : $("#size").val(),
				"color" : $("#color").val(),
				"gender" : $("#gender").val(),
				"age" : $("#age").val()
			});
			var stock={
				"repositId":$("#repositName").val(),		// TODO
				"count":$("#count").val()
			};
			var params = {
                "good" : good,
                "goodDetailList" : goodDetailList,
                "stock" : stock
			};

			$.ajax({
				url : '/ClothesShopPOS/good/add',
                type: "POST",
                contentType : "application/json;charset=utf-8",
                dataType : "json",
                data : JSON.stringify(params),
				success : function(data) {
                    console.log(data);
                    //data = JSON.parse(data);
				    if (data.statusCode=='0'){
				    	 alert("添加成功");
				    	 resetForm();
				    	 $("#addGood").modal('hide');
				    }else if(data.statusCode=='11'){
				    	alert("您的权限不够，无法添加商品！");
				    	$("#addGood").modal('hide');
				    } else{
				    	 alert("添加失败");
				    }
				}
			})
		}
		
		/*清空模态框<input>中的值*/
	    function resetForm(obj){
	    	var form=$(obj).parent().parent().find("form");
	    	form.find("input").each(function(i){
	    		form.find("input").eq(i).val("");
	    	});
	    }
	    
	    /*查看good的所有goodDetail*/
	    function showGoodDetail(obj){
	    	var th=obj.parentNode.parentNode;
	    	var goodId=th.cells[0].innerHTML;
	    	
	    	obj.setAttribute("data-target","#showGoodDetail");
	    	obj.setAttribute("data-toggle","modal");
	    	$.ajax({
	    		url : '/ClothesShopPOS/good/get_by_id',
					type : "get",
					cache : false,
					dataType:"json",
					data:{
						id:goodId
					},
					success:function(data){
						console.log(data);
						
						var resultGood=JSON.parse(data).result;
						var table=$("#goodDetailList");
					    
					    $.ajax({
					    	url:'/ClothesShopPOS/gooddetail/get_by_goodid',
					    	type : "get",
							cache : false,
							dataType:"json",
							data:{
								goodId:goodId
							},
							success:function(data){
								console.log(data);
								var resultGoodDetail=JSON.parse(data).result;
								if(resultGoodDetail.length==0){
									alert("此商品无详细信息");
								}else{
									temp1=$("<tr style='display:none'><td>"+resultGood.id+"</td></tr>");
									temp1.appendTo(table);
									for(var i=0;i<resultGoodDetail.length;i++){
										var temp=$("<tr><td style='display:none'>"+resultGoodDetail[i].id+"</td>"
										+"<td style='text-align:center'>"+resultGood.title+"</td>"
										+"<td>"+resultGoodDetail[i].referencePrice+"</td>"
										+"<td>"+resultGoodDetail[i].size+"</td>"
										+"<td>"+resultGoodDetail[i].age+"</td>"
										+"<td>"+resultGoodDetail[i].color+"</td>"
										+"<td>"+resultGoodDetail[i].gender+"</td>"
										+"<td style='display:none'>"+resultGoodDetail[i].goodId+"</td>"
										+"<td style='display:none'>"+resultGoodDetail[i].stock.id+"</td>"
										+"<td>"+resultGoodDetail[i].stock.count+"</td>"
										+"<td rowspan='2'><button type='button'  class='btn-getData btn btn-info btn-sm' onclick='showUpdateDetailModal(this)' style='margin-bottom:10px;'>更新</button>"
										+"<button type='button' class='btn btn-default btn-sm' onclick='delGoodDetail()'>删除</button></tr>"
										+"<tr><td style='text-align:center'>"+resultGood.goodNo+"</td></tr>");
										
										temp.appendTo(table);
									}
								}
							}
					    })//第二个ajax结束
					}
				})//第一个ajax结束
			}
	    	 
	    /*删除一个good*/
	    function delGood(obj){
	    	if(confirm("确定要删除吗？")){
	    		var th=obj.parentNode.parentNode;
	    		var goodId=th.cells[0].innerHTML;
	    		//alert(goodId);
	    		
	    		$.ajax({
	    			url : '/ClothesShopPOS/good/delete',
	    			type: "POST",
	                dataType : "json",
	                data : {
	                	id:goodId
	                },
					success : function(data) {
	                    console.log(data);
	                    //data = JSON.parse(data);//有调试功能的浏览器,可以在调试工具的控制台中打印信息。
					    if (data.statusCode=='0'){
					    	 alert("删除成功");
					    }else if(data.statusCode=='11'){
					    	alert("您的权限不够，不能执行此操作！");
					    }else{
					    	 alert("删除失败");
					    }
					   
					}
	    		})
	    	}
	    }
	    
	    /**在goodDetailList中点击关闭按钮后，清空goodDetailList**/
		function resetGoodDetailList(){
			$("#goodDetailList tbody").html("");
		}
		
		/* 删除一个goodDetail */
		function delGoodDetail(obj){
			var tr=$(obj).parent().parent();
			var tr1=tr.next();
	    	var detailId=tr.find("td").eq(0).text();
// 	    	alert(JSON.stringify(detailId));
	    	$.ajax({
	    			url : '/ClothesShopPOS/gooddetail/delete',
	    			type: "POST",
	                contentType : "application/json;charset=utf-8",
	                dataType : "json",
	                data : {
	                	id:detailId
	                },
					success : function(data) {
						tr1.remove();
						tr.remove();
	                    console.log(data);
	                    //data = JSON.parse(data);//有调试功能的浏览器,可以在调试工具的控制台中打印信息。
					    if (data.statusCode=='0'){
					    	 alert("删除成功");
					    }else if(data.statusCode=='11'){
					    	alert("您的权限不够，不能执行此操作！");
					    }else{
					    	 alert("删除失败");
					    }
					    
					}
	    		})
		}
	
		/* 显示添加goodDetail的模态框 */
		function showAddDetailModal(obj){
			var goodId=$(obj).parent().parent().parent().find("tbody").eq(0).find("td").eq(0).text();
			//alert(goodId);
	    	$(obj).attr("data-target","#addGoodDetail");
	    	$(obj).attr("data-toggle","modal");
	    	$(obj).attr("data-goodid",goodId);
	    	//obj.setAttribute("data-detailId",detailId);
	    	//alert($("#btn-getGoodId").data("goodid"));
		}
		
		/* 添加一个goodDetail */
		function addGoodDetail(){
			var goodId=$("#btn-getGoodId").data("goodid");
			
			$.ajax({
				url : '/ClothesShopPOS/gooddetail/add',
                type: "POST",
                dataType : "json",
                data : {
                	"goodId":goodId,
                	"referencePrice" : $("#detailPrice").val(),
					"size" : $("#detailSize").val(),
					"color" : $("#detailColor").val(),
					"gender" : $("#detailGender").val(),
					"age" : $("#detailAge").val(),
                	"repositId":$("#detailRepositName").val(),		// TODO
					"count":$("#detailCount").val()
                },
				success : function(data) {
                    console.log(data);
                    //data = JSON.parse(data);
				    if (data.statusCode=='0'){//todo
				    	 alert("添加成功");
				    	 //resetForm();
				    }else if(data.statusCode=='11'){
				    	alert("您的权限不够，不能执行此操作！");
				    }else{
				    	 alert("添加失败");
				    	
				    }
				    $("#addGoodDetail").modal('hide');
				    $("#showGoodDetail").modal('hide');
				    
				}
			})
		}
		
		
		/* 显示更新goodDetail的模态框 */
		function showUpdateDetailModal(obj){
			var detailId=$(obj).parent().parent().find("td").eq(0).text();
			var referencePrice=$(obj).parent().parent().find("td").eq(2).text();
			var size=$(obj).parent().parent().find("td").eq(3).text();
			var age=$(obj).parent().parent().find("td").eq(4).text();
			var color=$(obj).parent().parent().find("td").eq(5).text();
			var gender=$(obj).parent().parent().find("td").eq(6).text();
			var goodId=$(obj).parent().parent().find("td").eq(7).text();
			var stockId=$(obj).parent().parent().find("td").eq(8).text();
	    	$(obj).attr("data-target","#updateGoodDetail");
	    	$(obj).attr("data-toggle","modal");
	    	$(obj).attr("data-detailid",detailId);
	        $(obj).attr("data-ureferenceprice",referencePrice);
	    	$(obj).attr("data-usize",size);
	    	$(obj).attr("data-uage",age);
	    	$(obj).attr("data-ucolor",color);
	    	$(obj).attr("data-ugender",gender);
	    	$(obj).attr("data-ugoodid",goodId);
	    	$(obj).attr("data-ustockid",stockId);
	    	//alert(size);
	    	//alert($("#goodDetailList .btn-getData").data("ureferenceprice"));
	    	$("#updatedetailid").val($(obj).data("detailid"))
	    	$("#updateprice").val($(obj).data("ureferenceprice"));
	    	$("#updatesize").val($(obj).data("usize"));
	    	$("#updateage").val($(obj).data("uage"));
	    	$("#updatecolor").val($(obj).data("ucolor"));
	    	$("#updategender").val($(obj).data("ugender"));
	    	$("#updatestockid").val($(obj).data("ustockid"));
	    	$("#updategoodid").val($(obj).data("ugoodid"));
		}
		
		/* 更新一个goodDetail */
		function updateGoodDetail(obj){
			var detailId=$("#updatedetailid").val();
			var price=$("#updateprice").val();
			var size=$("#updatesize").val();
			var age=$("#updateage").val();
			var color=$("#updatecolor").val();
			var gender=$("#updategender").val();
			var goodId=$("#updategoodid").val();
			var stockId=$("#updatestockid").val()
			//alert(detailId);
			 $.ajax({
    			url : '/ClothesShopPOS/gooddetail/update',
    			type: "POST",
                dataType : "json",
                data : {
                	"id":detailId,
                	"referencePrice":price,
					"size" : size,
					"color" : color,
					"gender" : gender,
					"age" : age,
					"stockId":stockId ,
					"goodId":goodId
                },
				success : function(data) {
					//alert("test!");
                    console.log(data);
                    //data = JSON.parse(data);
				    if (data.statusCode=='0'){
				    	 alert("修改成功");
				    }else if(data.statusCode=='11'){
				    	alert("您的权限不够，不能执行此操作！");
				    }else{
				    	 alert("修改失败");
				    }
				    $("#updateGoodDetail").modal('hide');
					$("#showGoodDetail").modal('hide');
					$("#goodDetailList tbody").html("");
				}
    		})
		} 
		/*输入goodNo查找商品  */
		function searchGood(obj){
			
		    var search=$("#findGood").val();
			if(search != ""){
				$(obj).attr("data-toggle","modal");
				$(obj).attr("data-target","#showGoodDetail");
				$("#btn-cz").remove();
				$("#btn-getGoodId").remove();
				$.ajax({
	    			url : '/ClothesShopPOS/good/get_by_goodno',
	    			type: "GET",
	                dataType : "json",
	                data : {
						"goodNo":search
	                },
					success : function(data) {
	                    console.log(data);
	                    var goodObj = JSON.parse(data).result;
						var table=$("#goodDetailList");
						if(goodObj == null){
							//alert("查找不到此商品！");
							var sth=$("<tr><td>查找不到此商品！</td></tr>");
							sth.appendTo(table);
						}else{
							$.ajax({
						    	url:'/ClothesShopPOS/gooddetail/get_by_goodid',
						    	type : "get",
								cache : false,
								dataType:"json",
								data:{
									goodId:goodObj.id
								},
								success:function(data){
									var resultGoodDetail=JSON.parse(data).result;
									
									console.log(data);
									
									for(var i=0;i<resultGoodDetail.length;i++){
										var temp=$("<tr><td style='display:none'>"+goodObj.id+"</td>"
										+"<td style='text-align:center'>"+goodObj.title+"</td>"
										+"<td>"+resultGoodDetail[i].referencePrice+"</td>"
										+"<td>"+resultGoodDetail[i].size+"</td>"
										+"<td>"+resultGoodDetail[i].age+"</td>"
										+"<td>"+resultGoodDetail[i].color+"</td>"
										+"<td>"+resultGoodDetail[i].gender+"</td>"
										+"<td>"+resultGoodDetail[i].stock.count+"</td></tr>"
										+"<tr><td style='text-align:center'>"+goodObj.goodNo+"</td></tr>");
										
										temp.appendTo(table);
									}
									$("#findGood").val("");
								}
						    })//第二个ajax结束
						}
					}
	    		})  
				
			}else{
				alert("请输入正确的查找内容");
				
			} 
		}
		
	</script>
</body>
</html>